# use a computer to view your phone camera
# 电脑打开手机摄像头，手机上需要提前装好一个叫IP摄像头的APP
# 装好之后配置用户名和密码，连接时保证手机和电脑在同一局域网中

import cv2
import dlib

cv2.namedWindow("camera", 1)
# open ip camera
video = "http://admin:224114@192.168.0.108:8081/video"
capture = cv2.VideoCapture(video)


# visualize inspection results
def show_detection(image, faces):
    for face in faces:
        cv2.rectangle(image, (face.left(), face.top()), (face.right(), face.bottom()), (255, 0, 0), 3)
    return image


detector = dlib.get_frontal_face_detector()
while True:
    ret, frame = capture.read()
    gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    height = 600
    width = 1000
    cv2.imshow("object detection", cv2.resize(frame, (width, height)))
    if cv2.waitKey(20) & 0xFF == ord('q'):
        break


capture.release()
cv2.destroyAllWindows()
